home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 4889 / 4889.xpi / chrome / picnik.jar / content / domtweak.js < prev    next >
Text File  |  2007-07-30  |  4KB  |  102 lines

  1.  
  2.  
  3. var picnikDOMTweak = {
  4.     onLoad:function()
  5.     {
  6.         var e = document.getElementById("appcontent");
  7.         if(e)
  8.             addEventListener("DOMContentLoaded", function(ev) { picnikDOMTweak.domLoaded(ev);}, false);
  9.     },
  10.  
  11.     /***************************************************************/
  12.     /* GreaseMonkey-style DOM editing */
  13.     /* Fired every time some DOM finises loading */
  14.     domLoaded:function(e)
  15.     {
  16.         href = e.target.location.href;
  17.         for each (var site in this.tweakList)
  18.         {
  19.             if( site[0] instanceof RegExp )
  20.             {
  21.                 if( href.search(site[0]) != -1 )
  22.                     site[1](e.target)
  23.             }
  24.             else
  25.             {
  26.                 if( site[0](e.target) )
  27.                     site[1](e.target)
  28.             }
  29.         }
  30.     },
  31.  
  32.     /* Flickr photo pages */
  33.     tweakFlickr: function(e)
  34.     {
  35.         var links
  36.         links = e.getElementById('button_bar');
  37.         if (!links)
  38.         {
  39.             return;
  40.         }
  41.         else
  42.         {
  43.             var photoEditURL = picnikCommon.baseURL+"?import="+escape(e.location.href);
  44.  
  45.             // images URLs -- images aren't data-ized as FF doesn't like the crazy escaping when attempting to trigger the over/down states
  46.             var picnikButtonURLup = "chrome://picnik/content/picnik_grey.gif";
  47.             var picnikButtonURLover = "chrome://picnik/content/picnik_color.gif";
  48.             var picnikButtonURLdown = "chrome://picnik/content/picnik_color_down.gif";        
  49.             
  50.             // crate the new HTML element
  51.             var picbutton = e.createElement("href");
  52.             picbutton.innerHTML = "<a target=_blank href="+photoEditURL+" onMouseOver=\"document.picnikButton.src='"+ picnikButtonURLover +"'\" onMouseOut=\"document.picnikButton.src='"+ picnikButtonURLup +"'\" onMouseDown=\"document.picnikButton.src='"+ picnikButtonURLdown +"'\" onMouseUp=\"document.picnikButton.src='"+ picnikButtonURLover +"'\" style='outline: none;'><img src=" + picnikButtonURLup +" name='picnikButton' title='Edit this photo with Picnik' alt='Edit with Picnik' width='56' height='24'/></a>";
  53.         
  54.             // append it at the end of the button_bar list
  55.             links.appendChild(picbutton);
  56.         }
  57.     },
  58.  
  59.     /* Sites we know how to do GM like things to */
  60.     tweakList:[
  61.                 [/flickr\.com\/photos\/.*/g, function(e){picnikDOMTweak.tweakFlickr(e)} ]
  62.         /*        [picnik_smugmug_check, picnik_smugmug] */
  63.             ]
  64. };
  65. window.addEventListener("load", function(e) { picnikDOMTweak.onLoad(e); }, false);
  66.  
  67. /*
  68. function picnik_smugmug_check(e)
  69. {
  70.     return e.getElementById('smugmug')!=null
  71. }
  72.  
  73. function picnik_smugmug(e)
  74. {
  75.     var links
  76.  
  77.     links = e.getElementById('imageInfo');
  78.     if (!links)
  79.     {
  80.         return;
  81.     }
  82.     else
  83.     {
  84.         var photoEditURL = "javascript:void(window.location.href='"+picnikCommon.baseURL+"?import='+escape(document.getElementById(\"mainImage\").src))";
  85.  
  86.         // images URLs -- images aren't data-ized as FF doesn't like the crazy escaping when attempting to trigger the over/down states
  87.         var picnikButtonURLup = "chrome://picnik/content/picnik_grey.gif";
  88.         var picnikButtonURLover = "chrome://picnik/content/picnik_color.gif";
  89.         var picnikButtonURLdown = "chrome://picnik/content/picnik_color_down.gif";        
  90.         
  91.         // crate the new HTML element
  92.         var picbutton = e.createElement("href");
  93.         picbutton.innerHTML = "<a href="+photoEditURL+" onMouseOver=\"document.picnikButton.src='"+ picnikButtonURLover +"'\" onMouseOut=\"document.picnikButton.src='"+ picnikButtonURLup +"'\" onMouseDown=\"document.picnikButton.src='"+ picnikButtonURLdown +"'\" onMouseUp=\"document.picnikButton.src='"+ picnikButtonURLover +"'\" style='outline: none;'><img src=" + picnikButtonURLup +" name='picnikButton' title='Edit this photo with Picnik' alt='Edit with Picnik' width='56' height='24'/></a>";
  94.     
  95.         // append it at the end of the button_bar list
  96.         links.appendChild(picbutton);
  97.     }
  98. }
  99. */
  100.  
  101.  
  102.